.class public Lcom/noshufou/android/su/provider/PermissionsProvider;
.super Landroid/content/ContentProvider;
.source "PermissionsProvider.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/noshufou/android/su/provider/PermissionsProvider$Apps;,
        Lcom/noshufou/android/su/provider/PermissionsProvider$Logs;,
        Lcom/noshufou/android/su/provider/PermissionsProvider$SuDbOpenHelper;
    }
.end annotation


# static fields
.field private static final APPS:I = 0x64

.field private static final APP_CLEAN:I = 0x6b

.field private static final APP_COUNT:I = 0x69

.field private static final APP_COUNT_TYPE:I = 0x6a

.field private static final APP_ID:I = 0x65

.field private static final APP_ID_LOGS:I = 0x66

.field private static final APP_UID:I = 0x67

.field private static final APP_UID_LOGS:I = 0x68

.field public static final AUTHORITY:Ljava/lang/String; = "com.noshufou.android.su.provider"

.field private static final LOGS:I = 0xc8

.field private static final LOGS_APP_ID:I = 0xca

.field private static final LOGS_TYPE:I = 0xcb

.field private static final TAG:Ljava/lang/String; = "Su.PermissionsProvider"

.field private static final sAppsProjectionMap:Ljava/util/HashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/HashMap",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field

.field private static final sLogsProjectionMap:Ljava/util/HashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/HashMap",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field

.field private static final sUriMatcher:Landroid/content/UriMatcher;


# instance fields
.field private mContext:Landroid/content/Context;

.field private mDb:Landroid/database/sqlite/SQLiteDatabase;

.field private mDbHelper:Lcom/noshufou/android/su/provider/PermissionsProvider$SuDbOpenHelper;


# direct methods
.method static constructor <clinit>()V
    .locals 4

    .prologue
    .line 128
    new-instance v0, Landroid/content/UriMatcher;

    const/4 v1, -0x1

    invoke-direct {v0, v1}, Landroid/content/UriMatcher;-><init>(I)V

    sput-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    .line 130
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    const-string v1, "com.noshufou.android.su.provider"

    const-string v2, "apps"

    const/16 v3, 0x64

    invoke-virtual {v0, v1, v2, v3}, Landroid/content/UriMatcher;->addURI(Ljava/lang/String;Ljava/lang/String;I)V

    .line 131
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    const-string v1, "com.noshufou.android.su.provider"

    const-string v2, "apps/#"

    const/16 v3, 0x65

    invoke-virtual {v0, v1, v2, v3}, Landroid/content/UriMatcher;->addURI(Ljava/lang/String;Ljava/lang/String;I)V

    .line 132
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    const-string v1, "com.noshufou.android.su.provider"

    const-string v2, "apps/clean"

    const/16 v3, 0x6b

    invoke-virtual {v0, v1, v2, v3}, Landroid/content/UriMatcher;->addURI(Ljava/lang/String;Ljava/lang/String;I)V

    .line 133
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    const-string v1, "com.noshufou.android.su.provider"

    const-string v2, "apps/#/logs"

    const/16 v3, 0x66

    invoke-virtual {v0, v1, v2, v3}, Landroid/content/UriMatcher;->addURI(Ljava/lang/String;Ljava/lang/String;I)V

    .line 134
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    const-string v1, "com.noshufou.android.su.provider"

    const-string v2, "apps/uid/#"

    const/16 v3, 0x67

    invoke-virtual {v0, v1, v2, v3}, Landroid/content/UriMatcher;->addURI(Ljava/lang/String;Ljava/lang/String;I)V

    .line 135
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    const-string v1, "com.noshufou.android.su.provider"

    const-string v2, "apps/uid/#/logs"

    const/16 v3, 0x68

    invoke-virtual {v0, v1, v2, v3}, Landroid/content/UriMatcher;->addURI(Ljava/lang/String;Ljava/lang/String;I)V

    .line 136
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    const-string v1, "com.noshufou.android.su.provider"

    const-string v2, "apps/count"

    const/16 v3, 0x69

    invoke-virtual {v0, v1, v2, v3}, Landroid/content/UriMatcher;->addURI(Ljava/lang/String;Ljava/lang/String;I)V

    .line 137
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    const-string v1, "com.noshufou.android.su.provider"

    const-string v2, "apps/count/#"

    const/16 v3, 0x6a

    invoke-virtual {v0, v1, v2, v3}, Landroid/content/UriMatcher;->addURI(Ljava/lang/String;Ljava/lang/String;I)V

    .line 138
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    const-string v1, "com.noshufou.android.su.provider"

    const-string v2, "logs"

    const/16 v3, 0xc8

    invoke-virtual {v0, v1, v2, v3}, Landroid/content/UriMatcher;->addURI(Ljava/lang/String;Ljava/lang/String;I)V

    .line 139
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    const-string v1, "com.noshufou.android.su.provider"

    const-string v2, "logs/#"

    const/16 v3, 0xca

    invoke-virtual {v0, v1, v2, v3}, Landroid/content/UriMatcher;->addURI(Ljava/lang/String;Ljava/lang/String;I)V

    .line 140
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    const-string v1, "com.noshufou.android.su.provider"

    const-string v2, "logs/type/#"

    const/16 v3, 0xcb

    invoke-virtual {v0, v1, v2, v3}, Landroid/content/UriMatcher;->addURI(Ljava/lang/String;Ljava/lang/String;I)V

    .line 145
    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    sput-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sAppsProjectionMap:Ljava/util/HashMap;

    .line 146
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sAppsProjectionMap:Ljava/util/HashMap;

    const-string v1, "_id"

    const-string v2, "apps._id AS _id"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 147
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sAppsProjectionMap:Ljava/util/HashMap;

    const-string v1, "uid"

    const-string v2, "apps.uid"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 148
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sAppsProjectionMap:Ljava/util/HashMap;

    const-string v1, "package"

    const-string v2, "apps.package"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 149
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sAppsProjectionMap:Ljava/util/HashMap;

    const-string v1, "name"

    const-string v2, "apps.name"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 150
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sAppsProjectionMap:Ljava/util/HashMap;

    const-string v1, "exec_uid"

    const-string v2, "apps.exec_uid"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 151
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sAppsProjectionMap:Ljava/util/HashMap;

    const-string v1, "exec_cmd"

    const-string v2, "apps.exec_cmd"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 152
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sAppsProjectionMap:Ljava/util/HashMap;

    const-string v1, "allow"

    const-string v2, "apps.allow"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 153
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sAppsProjectionMap:Ljava/util/HashMap;

    const-string v1, "date"

    const-string v2, "logs.date"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 154
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sAppsProjectionMap:Ljava/util/HashMap;

    const-string v1, "type"

    const-string v2, "logs.type"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 155
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sAppsProjectionMap:Ljava/util/HashMap;

    const-string v1, "notifications"

    const-string v2, "apps.notifications"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 156
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sAppsProjectionMap:Ljava/util/HashMap;

    const-string v1, "logging"

    const-string v2, "apps.logging"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 157
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sAppsProjectionMap:Ljava/util/HashMap;

    const-string v1, "dirty"

    const-string v2, "apps.dirty"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 162
    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    sput-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sLogsProjectionMap:Ljava/util/HashMap;

    .line 163
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sLogsProjectionMap:Ljava/util/HashMap;

    const-string v1, "_id"

    const-string v2, "logs._id AS _id"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 164
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sLogsProjectionMap:Ljava/util/HashMap;

    const-string v1, "app_id"

    const-string v2, "logs.app_id"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 165
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sLogsProjectionMap:Ljava/util/HashMap;

    const-string v1, "uid"

    const-string v2, "apps.uid"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 166
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sLogsProjectionMap:Ljava/util/HashMap;

    const-string v1, "name"

    const-string v2, "apps.name"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 167
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sLogsProjectionMap:Ljava/util/HashMap;

    const-string v1, "package"

    const-string v2, "apps.package"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 168
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sLogsProjectionMap:Ljava/util/HashMap;

    const-string v1, "date"

    const-string v2, "logs.date"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 169
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sLogsProjectionMap:Ljava/util/HashMap;

    const-string v1, "type"

    const-string v2, "logs.type"

    invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 37
    return-void
.end method

.method public constructor <init>()V
    .locals 1

    .prologue
    const/4 v0, 0x0

    .line 37
    invoke-direct {p0}, Landroid/content/ContentProvider;-><init>()V

    .line 173
    iput-object v0, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDbHelper:Lcom/noshufou/android/su/provider/PermissionsProvider$SuDbOpenHelper;

    .line 174
    iput-object v0, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    .line 37
    return-void
.end method

.method static synthetic access$0(Lcom/noshufou/android/su/provider/PermissionsProvider;)Landroid/content/Context;
    .locals 1
    .parameter

    .prologue
    .line 172
    iget-object v0, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mContext:Landroid/content/Context;

    return-object v0
.end method

.method private ensureDb()Z
    .locals 1

    .prologue
    .line 455
    iget-object v0, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    if-nez v0, :cond_0

    .line 456
    iget-object v0, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDbHelper:Lcom/noshufou/android/su/provider/PermissionsProvider$SuDbOpenHelper;

    invoke-virtual {v0}, Lcom/noshufou/android/su/provider/PermissionsProvider$SuDbOpenHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    iput-object v0, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    .line 457
    iget-object v0, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    if-nez v0, :cond_0

    const/4 v0, 0x0

    .line 459
    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x1

    goto :goto_0
.end method


# virtual methods
.method public delete(Landroid/net/Uri;Ljava/lang/String;[Ljava/lang/String;)I
    .locals 9
    .parameter "uri"
    .parameter "selection"
    .parameter "selectionArgs"

    .prologue
    const/4 v8, 0x0

    const/4 v7, 0x1

    .line 399
    invoke-direct {p0}, Lcom/noshufou/android/su/provider/PermissionsProvider;->ensureDb()Z

    move-result v2

    if-nez v2, :cond_0

    const/4 v0, -0x1

    .line 451
    :goto_0
    return v0

    .line 401
    :cond_0
    const/4 v0, 0x0

    .line 403
    .local v0, count:I
    new-instance v1, Landroid/content/ContentValues;

    invoke-direct {v1}, Landroid/content/ContentValues;-><init>()V

    .line 404
    .local v1, deleteAppValues:Landroid/content/ContentValues;
    const-string v2, "allow"

    const/4 v3, -0x2

    invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v3

    invoke-virtual {v1, v2, v3}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Integer;)V

    .line 405
    const-string v2, "dirty"

    invoke-static {v7}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v3

    invoke-virtual {v1, v2, v3}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Integer;)V

    .line 407
    sget-object v2, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    invoke-virtual {v2, p1}, Landroid/content/UriMatcher;->match(Landroid/net/Uri;)I

    move-result v2

    sparse-switch v2, :sswitch_data_0

    .line 447
    new-instance v2, Ljava/lang/IllegalArgumentException;

    new-instance v3, Ljava/lang/StringBuilder;

    const-string v4, "Unsupported URI: "

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v2

    .line 411
    :sswitch_0
    iget-object v2, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    const-string v3, "apps"

    invoke-virtual {v2, v3, v1, p2, p3}, Landroid/database/sqlite/SQLiteDatabase;->update(Ljava/lang/String;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;)I

    move-result v0

    .line 413
    iget-object v2, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mContext:Landroid/content/Context;

    invoke-static {v2}, Lcom/noshufou/android/su/util/Util;->updatePermissionsDb(Landroid/content/Context;)V

    .line 449
    :goto_1
    invoke-virtual {p0}, Lcom/noshufou/android/su/provider/PermissionsProvider;->getContext()Landroid/content/Context;

    move-result-object v2

    invoke-virtual {v2}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v2

    invoke-virtual {v2, p1, v8}, Landroid/content/ContentResolver;->notifyChange(Landroid/net/Uri;Landroid/database/ContentObserver;)V

    .line 450
    invoke-virtual {p0}, Lcom/noshufou/android/su/provider/PermissionsProvider;->getContext()Landroid/content/Context;

    move-result-object v2

    invoke-virtual {v2}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v2

    sget-object v3, Lcom/noshufou/android/su/provider/PermissionsProvider$Apps;->CONTENT_URI:Landroid/net/Uri;

    invoke-virtual {v2, v3, v8}, Landroid/content/ContentResolver;->notifyChange(Landroid/net/Uri;Landroid/database/ContentObserver;)V

    goto :goto_0

    .line 416
    :sswitch_1
    iget-object v3, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    const-string v4, "apps"

    .line 417
    new-instance v5, Ljava/lang/StringBuilder;

    const-string v2, "_id="

    invoke-direct {v5, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {p1}, Landroid/net/Uri;->getPathSegments()Ljava/util/List;

    move-result-object v2

    invoke-interface {v2, v7}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/String;

    invoke-virtual {v5, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    .line 418
    invoke-static {p2}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v2

    if-nez v2, :cond_1

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v6, " AND ("

    invoke-direct {v2, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 419
    invoke-virtual {v2, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v6, ")"

    invoke-virtual {v2, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 418
    :goto_2
    invoke-virtual {v5, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 417
    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 416
    invoke-virtual {v3, v4, v1, v2, p3}, Landroid/database/sqlite/SQLiteDatabase;->update(Ljava/lang/String;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;)I

    move-result v0

    .line 421
    iget-object v2, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mContext:Landroid/content/Context;

    invoke-static {v2}, Lcom/noshufou/android/su/util/Util;->updatePermissionsDb(Landroid/content/Context;)V

    .line 425
    :sswitch_2
    iget-object v3, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    const-string v4, "logs"

    .line 426
    new-instance v5, Ljava/lang/StringBuilder;

    const-string v2, "app_id="

    invoke-direct {v5, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {p1}, Landroid/net/Uri;->getPathSegments()Ljava/util/List;

    move-result-object v2

    invoke-interface {v2, v7}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/String;

    invoke-virtual {v5, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    .line 427
    invoke-static {p2}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v2

    if-nez v2, :cond_2

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v6, " AND ("

    invoke-direct {v2, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 428
    invoke-virtual {v2, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v6, ")"

    invoke-virtual {v2, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 427
    :goto_3
    invoke-virtual {v5, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 426
    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 429
    invoke-virtual {v3, v4, v2, p3}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I

    move-result v2

    add-int/2addr v0, v2

    .line 430
    goto/16 :goto_1

    .line 419
    :cond_1
    const-string v2, ""

    goto :goto_2

    .line 428
    :cond_2
    const-string v2, ""

    goto :goto_3

    .line 433
    :sswitch_3
    iget-object v3, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    const-string v4, "apps"

    .line 434
    new-instance v5, Ljava/lang/StringBuilder;

    const-string v2, "uid="

    invoke-direct {v5, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {p1}, Landroid/net/Uri;->getPathSegments()Ljava/util/List;

    move-result-object v2

    const/4 v6, 0x2

    invoke-interface {v2, v6}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/String;

    invoke-virtual {v5, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    .line 435
    invoke-static {p2}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v2

    if-nez v2, :cond_3

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v6, " AND ("

    invoke-direct {v2, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 436
    invoke-virtual {v2, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v6, ")"

    invoke-virtual {v2, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 435
    :goto_4
    invoke-virtual {v5, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 434
    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 433
    invoke-virtual {v3, v4, v1, v2, p3}, Landroid/database/sqlite/SQLiteDatabase;->update(Ljava/lang/String;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;)I

    move-result v0

    .line 438
    iget-object v2, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mContext:Landroid/content/Context;

    invoke-static {v2}, Lcom/noshufou/android/su/util/Util;->updatePermissionsDb(Landroid/content/Context;)V

    goto/16 :goto_1

    .line 436
    :cond_3
    const-string v2, ""

    goto :goto_4

    .line 441
    :sswitch_4
    iget-object v2, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    const-string v3, "apps"

    invoke-virtual {v2, v3, p2, p3}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I

    move-result v0

    .line 442
    goto/16 :goto_1

    .line 444
    :sswitch_5
    iget-object v2, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    const-string v3, "logs"

    invoke-virtual {v2, v3, p2, p3}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I

    move-result v0

    .line 445
    goto/16 :goto_1

    .line 407
    :sswitch_data_0
    .sparse-switch
        0x64 -> :sswitch_0
        0x65 -> :sswitch_1
        0x66 -> :sswitch_2
        0x67 -> :sswitch_3
        0x6b -> :sswitch_4
        0xc8 -> :sswitch_5
        0xca -> :sswitch_2
    .end sparse-switch
.end method

.method public getType(Landroid/net/Uri;)Ljava/lang/String;
    .locals 3
    .parameter "uri"

    .prologue
    .line 185
    sget-object v0, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    invoke-virtual {v0, p1}, Landroid/content/UriMatcher;->match(Landroid/net/Uri;)I

    move-result v0

    sparse-switch v0, :sswitch_data_0

    .line 200
    new-instance v0, Ljava/lang/IllegalArgumentException;

    new-instance v1, Ljava/lang/StringBuilder;

    const-string v2, "Unsupported URI: "

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 187
    :sswitch_0
    const-string v0, "vnd.android.cursor.dir/vnd.noshufou.superuser.apps "

    .line 198
    :goto_0
    return-object v0

    .line 192
    :sswitch_1
    const-string v0, "vnd.android.cursor.item/vnd.noshufou.superuser.apps "

    goto :goto_0

    .line 198
    :sswitch_2
    const-string v0, "vnd.android.cursor.dir/vnd.noshufou.superuser.logs "

    goto :goto_0

    .line 185
    nop

    :sswitch_data_0
    .sparse-switch
        0x64 -> :sswitch_0
        0x65 -> :sswitch_1
        0x66 -> :sswitch_2
        0x67 -> :sswitch_1
        0x68 -> :sswitch_2
        0x69 -> :sswitch_1
        0x6a -> :sswitch_1
        0xc8 -> :sswitch_2
        0xca -> :sswitch_2
        0xcb -> :sswitch_2
    .end sparse-switch
.end method

.method public insert(Landroid/net/Uri;Landroid/content/ContentValues;)Landroid/net/Uri;
    .locals 15
    .parameter "uri"
    .parameter "values"

    .prologue
    .line 289
    invoke-direct {p0}, Lcom/noshufou/android/su/provider/PermissionsProvider;->ensureDb()Z

    move-result v1

    if-nez v1, :cond_0

    const/4 v12, 0x0

    .line 349
    :goto_0
    return-object v12

    .line 291
    :cond_0
    const-wide/16 v13, 0x0

    .line 292
    .local v13, rowId:J
    const/4 v12, 0x0

    .line 294
    .local v12, returnUri:Landroid/net/Uri;
    sget-object v1, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    move-object/from16 v0, p1

    invoke-virtual {v1, v0}, Landroid/content/UriMatcher;->match(Landroid/net/Uri;)I

    move-result v1

    sparse-switch v1, :sswitch_data_0

    .line 344
    new-instance v1, Ljava/lang/IllegalArgumentException;

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "Unsupported URI: "

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    move-object/from16 v0, p1

    invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v1

    .line 297
    :sswitch_0
    const-string v1, "dirty"

    const-string v2, "1"

    move-object/from16 v0, p2

    invoke-virtual {v0, v1, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 299
    :try_start_0
    iget-object v1, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    const-string v2, "apps"

    const/4 v3, 0x0

    move-object/from16 v0, p2

    invoke-virtual {v1, v2, v3, v0}, Landroid/database/sqlite/SQLiteDatabase;->insertOrThrow(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;)J
    :try_end_0
    .catch Landroid/database/SQLException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-wide v13

    .line 319
    :goto_1
    const-string v1, "allow"

    move-object/from16 v0, p2

    invoke-virtual {v0, v1}, Landroid/content/ContentValues;->getAsInteger(Ljava/lang/String;)Ljava/lang/Integer;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/Integer;->intValue()I

    move-result v1

    const/4 v2, -0x1

    if-eq v1, v2, :cond_1

    .line 320
    new-instance v11, Landroid/content/ContentValues;

    invoke-direct {v11}, Landroid/content/ContentValues;-><init>()V

    .line 321
    .local v11, logValues:Landroid/content/ContentValues;
    const-string v1, "app_id"

    invoke-static {v13, v14}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v2

    invoke-virtual {v11, v1, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Long;)V

    .line 322
    const-string v1, "date"

    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v2

    invoke-static {v2, v3}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v2

    invoke-virtual {v11, v1, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Long;)V

    .line 323
    const-string v1, "type"

    const/4 v2, 0x2

    invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v2

    invoke-virtual {v11, v1, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Integer;)V

    .line 324
    iget-object v1, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    const-string v2, "logs"

    const/4 v3, 0x0

    invoke-virtual {v1, v2, v3, v11}, Landroid/database/sqlite/SQLiteDatabase;->insert(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;)J

    .line 326
    .end local v11           #logValues:Landroid/content/ContentValues;
    :cond_1
    iget-object v1, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mContext:Landroid/content/Context;

    invoke-static {v1}, Lcom/noshufou/android/su/util/Util;->updatePermissionsDb(Landroid/content/Context;)V

    .line 327
    sget-object v1, Lcom/noshufou/android/su/provider/PermissionsProvider$Apps;->CONTENT_URI:Landroid/net/Uri;

    invoke-static {v1, v13, v14}, Landroid/content/ContentUris;->withAppendedId(Landroid/net/Uri;J)Landroid/net/Uri;

    move-result-object v12

    .line 347
    :goto_2
    const-wide/16 v1, -0x1

    cmp-long v1, v13, v1

    if-lez v1, :cond_3

    .line 348
    invoke-virtual {p0}, Lcom/noshufou/android/su/provider/PermissionsProvider;->getContext()Landroid/content/Context;

    move-result-object v1

    invoke-virtual {v1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v1

    const/4 v2, 0x0

    invoke-virtual {v1, v12, v2}, Landroid/content/ContentResolver;->notifyChange(Landroid/net/Uri;Landroid/database/ContentObserver;)V

    goto/16 :goto_0

    .line 300
    :catch_0
    move-exception v10

    .line 301
    .local v10, e:Landroid/database/SQLException;
    const-string v4, "uid=? AND exec_uid=? AND exec_cmd=?"

    .line 303
    .local v4, where:Ljava/lang/String;
    const/4 v1, 0x3

    new-array v5, v1, [Ljava/lang/String;

    const/4 v1, 0x0

    const-string v2, "uid"

    move-object/from16 v0, p2

    invoke-virtual {v0, v2}, Landroid/content/ContentValues;->getAsString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    aput-object v2, v5, v1

    const/4 v1, 0x1

    .line 304
    const-string v2, "exec_uid"

    move-object/from16 v0, p2

    invoke-virtual {v0, v2}, Landroid/content/ContentValues;->getAsString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    aput-object v2, v5, v1

    const/4 v1, 0x2

    .line 305
    const-string v2, "exec_cmd"

    move-object/from16 v0, p2

    invoke-virtual {v0, v2}, Landroid/content/ContentValues;->getAsString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    aput-object v2, v5, v1

    .line 306
    .local v5, whereArgs:[Ljava/lang/String;
    iget-object v1, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    const-string v2, "apps"

    move-object/from16 v0, p2

    invoke-virtual {v1, v2, v0, v4, v5}, Landroid/database/sqlite/SQLiteDatabase;->update(Ljava/lang/String;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;)I

    .line 309
    iget-object v1, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    const-string v2, "apps"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/String;

    const/4 v6, 0x0

    const-string v7, "_id"

    aput-object v7, v3, v6

    .line 312
    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    .line 309
    invoke-virtual/range {v1 .. v8}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v9

    .line 313
    .local v9, c:Landroid/database/Cursor;
    invoke-interface {v9}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v1

    if-eqz v1, :cond_2

    .line 314
    const/4 v1, 0x0

    invoke-interface {v9, v1}, Landroid/database/Cursor;->getLong(I)J

    move-result-wide v13

    .line 316
    :cond_2
    invoke-interface {v9}, Landroid/database/Cursor;->close()V

    goto/16 :goto_1

    .line 332
    .end local v4           #where:Ljava/lang/String;
    .end local v5           #whereArgs:[Ljava/lang/String;
    .end local v9           #c:Landroid/database/Cursor;
    .end local v10           #e:Landroid/database/SQLException;
    :sswitch_1
    const-string v2, "app_id"

    invoke-virtual/range {p1 .. p1}, Landroid/net/Uri;->getPathSegments()Ljava/util/List;

    move-result-object v1

    const/4 v3, 0x1

    invoke-interface {v1, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/String;

    move-object/from16 v0, p2

    invoke-virtual {v0, v2, v1}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 333
    iget-object v1, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    const-string v2, "logs"

    const/4 v3, 0x0

    move-object/from16 v0, p2

    invoke-virtual {v1, v2, v3, v0}, Landroid/database/sqlite/SQLiteDatabase;->insert(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;)J

    move-result-wide v13

    .line 334
    sget-object v1, Lcom/noshufou/android/su/provider/PermissionsProvider$Logs;->CONTENT_URI:Landroid/net/Uri;

    invoke-static {v1, v13, v14}, Landroid/content/ContentUris;->withAppendedId(Landroid/net/Uri;J)Landroid/net/Uri;

    move-result-object v12

    .line 337
    invoke-virtual {p0}, Lcom/noshufou/android/su/provider/PermissionsProvider;->getContext()Landroid/content/Context;

    move-result-object v1

    invoke-virtual {v1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v2

    .line 338
    sget-object v3, Lcom/noshufou/android/su/provider/PermissionsProvider$Logs;->CONTENT_URI:Landroid/net/Uri;

    .line 339
    invoke-virtual/range {p1 .. p1}, Landroid/net/Uri;->getPathSegments()Ljava/util/List;

    move-result-object v1

    const/4 v6, 0x1

    invoke-interface {v1, v6}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/String;

    invoke-static {v1}, Ljava/lang/Long;->parseLong(Ljava/lang/String;)J

    move-result-wide v6

    .line 338
    invoke-static {v3, v6, v7}, Landroid/content/ContentUris;->withAppendedId(Landroid/net/Uri;J)Landroid/net/Uri;

    move-result-object v1

    .line 340
    const/4 v3, 0x0

    .line 337
    invoke-virtual {v2, v1, v3}, Landroid/content/ContentResolver;->notifyChange(Landroid/net/Uri;Landroid/database/ContentObserver;)V

    .line 341
    invoke-virtual {p0}, Lcom/noshufou/android/su/provider/PermissionsProvider;->getContext()Landroid/content/Context;

    move-result-object v1

    invoke-virtual {v1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v1

    sget-object v2, Lcom/noshufou/android/su/provider/PermissionsProvider$Apps;->CONTENT_URI:Landroid/net/Uri;

    const/4 v3, 0x0

    invoke-virtual {v1, v2, v3}, Landroid/content/ContentResolver;->notifyChange(Landroid/net/Uri;Landroid/database/ContentObserver;)V

    goto/16 :goto_2

    .line 351
    :cond_3
    new-instance v1, Landroid/database/SQLException;

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "Failed to insert row into "

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    move-object/from16 v0, p1

    invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Landroid/database/SQLException;-><init>(Ljava/lang/String;)V

    throw v1

    .line 294
    :sswitch_data_0
    .sparse-switch
        0x64 -> :sswitch_0
        0x66 -> :sswitch_1
        0xca -> :sswitch_1
    .end sparse-switch
.end method

.method public onCreate()Z
    .locals 2

    .prologue
    .line 178
    invoke-virtual {p0}, Lcom/noshufou/android/su/provider/PermissionsProvider;->getContext()Landroid/content/Context;

    move-result-object v0

    iput-object v0, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mContext:Landroid/content/Context;

    .line 179
    new-instance v0, Lcom/noshufou/android/su/provider/PermissionsProvider$SuDbOpenHelper;

    iget-object v1, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mContext:Landroid/content/Context;

    invoke-direct {v0, p0, v1}, Lcom/noshufou/android/su/provider/PermissionsProvider$SuDbOpenHelper;-><init>(Lcom/noshufou/android/su/provider/PermissionsProvider;Landroid/content/Context;)V

    iput-object v0, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDbHelper:Lcom/noshufou/android/su/provider/PermissionsProvider$SuDbOpenHelper;

    .line 180
    iget-object v0, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDbHelper:Lcom/noshufou/android/su/provider/PermissionsProvider$SuDbOpenHelper;

    if-nez v0, :cond_0

    const/4 v0, 0x0

    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x1

    goto :goto_0
.end method

.method public query(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
    .locals 12
    .parameter "uri"
    .parameter "projection"
    .parameter "selection"
    .parameter "selectionArgs"
    .parameter "sortOrder"

    .prologue
    .line 207
    invoke-direct {p0}, Lcom/noshufou/android/su/provider/PermissionsProvider;->ensureDb()Z

    move-result v1

    if-nez v1, :cond_0

    const/4 v8, 0x0

    .line 284
    :goto_0
    return-object v8

    .line 209
    :cond_0
    new-instance v0, Landroid/database/sqlite/SQLiteQueryBuilder;

    invoke-direct {v0}, Landroid/database/sqlite/SQLiteQueryBuilder;-><init>()V

    .line 210
    .local v0, qBuilder:Landroid/database/sqlite/SQLiteQueryBuilder;
    const/4 v9, 0x0

    check-cast v9, [Ljava/lang/String;

    .line 211
    .local v9, defaultProjection:[Ljava/lang/String;
    const/4 v5, 0x0

    .line 213
    .local v5, groupBy:Ljava/lang/String;
    sget-object v1, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    invoke-virtual {v1, p1}, Landroid/content/UriMatcher;->match(Landroid/net/Uri;)I

    move-result v11

    .line 215
    .local v11, uriMatch:I
    sparse-switch v11, :sswitch_data_0

    .line 244
    new-instance v1, Ljava/lang/IllegalArgumentException;

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "Unsupported URI: "

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v1

    .line 219
    :sswitch_0
    const-string v1, "apps LEFT OUTER JOIN logs ON apps._id=logs.app_id"

    invoke-virtual {v0, v1}, Landroid/database/sqlite/SQLiteQueryBuilder;->setTables(Ljava/lang/String;)V

    .line 220
    sget-object v1, Lcom/noshufou/android/su/provider/PermissionsProvider;->sAppsProjectionMap:Ljava/util/HashMap;

    invoke-virtual {v0, v1}, Landroid/database/sqlite/SQLiteQueryBuilder;->setProjectionMap(Ljava/util/Map;)V

    .line 221
    sget-object v9, Lcom/noshufou/android/su/provider/PermissionsProvider$Apps;->DEFAULT_PROJECTION:[Ljava/lang/String;

    .line 223
    const-string v5, "apps._id"

    .line 224
    if-nez p5, :cond_1

    const-string p5, "apps.allow DESC, apps.name ASC"

    .line 225
    :cond_1
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static/range {p5 .. p5}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-direct {v2, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-static/range {p5 .. p5}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v1

    if-nez v1, :cond_3

    const-string v1, ", "

    :goto_1
    invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p5

    .line 226
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-static/range {p5 .. p5}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v2, "date"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, " DESC"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p5

    .line 248
    :goto_2
    sparse-switch v11, :sswitch_data_1

    .line 270
    :goto_3
    if-nez p2, :cond_2

    move-object p2, v9

    .line 271
    :cond_2
    const/4 v8, 0x0

    .line 273
    .local v8, c:Landroid/database/Cursor;
    :try_start_0
    iget-object v1, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    .line 278
    const/4 v6, 0x0

    move-object v2, p2

    move-object v3, p3

    move-object/from16 v4, p4

    move-object/from16 v7, p5

    .line 273
    invoke-virtual/range {v0 .. v7}, Landroid/database/sqlite/SQLiteQueryBuilder;->query(Landroid/database/sqlite/SQLiteDatabase;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
    :try_end_0
    .catch Landroid/database/sqlite/SQLiteException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v8

    .line 283
    :goto_4
    iget-object v1, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mContext:Landroid/content/Context;

    invoke-virtual {v1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v1

    invoke-interface {v8, v1, p1}, Landroid/database/Cursor;->setNotificationUri(Landroid/content/ContentResolver;Landroid/net/Uri;)V

    goto/16 :goto_0

    .line 225
    .end local v8           #c:Landroid/database/Cursor;
    :cond_3
    const-string v1, ""

    goto :goto_1

    .line 233
    :sswitch_1
    const-string v1, "logs LEFT OUTER JOIN apps ON logs.app_id=apps._id"

    invoke-virtual {v0, v1}, Landroid/database/sqlite/SQLiteQueryBuilder;->setTables(Ljava/lang/String;)V

    .line 234
    sget-object v1, Lcom/noshufou/android/su/provider/PermissionsProvider;->sLogsProjectionMap:Ljava/util/HashMap;

    invoke-virtual {v0, v1}, Landroid/database/sqlite/SQLiteQueryBuilder;->setProjectionMap(Ljava/util/Map;)V

    .line 235
    sget-object v9, Lcom/noshufou/android/su/provider/PermissionsProvider$Logs;->DEFAULT_PROJECTION:[Ljava/lang/String;

    .line 236
    if-nez p5, :cond_4

    const-string p5, "logs.date DESC"

    .line 237
    :cond_4
    goto :goto_2

    .line 240
    :sswitch_2
    const-string v1, "apps"

    invoke-virtual {v0, v1}, Landroid/database/sqlite/SQLiteQueryBuilder;->setTables(Ljava/lang/String;)V

    .line 241
    const/4 v1, 0x1

    new-array v9, v1, [Ljava/lang/String;

    .end local v9           #defaultProjection:[Ljava/lang/String;
    const/4 v1, 0x0

    const-string v2, "COUNT() as rows"

    aput-object v2, v9, v1

    .line 242
    .restart local v9       #defaultProjection:[Ljava/lang/String;
    goto :goto_2

    .line 250
    :sswitch_3
    new-instance v2, Ljava/lang/StringBuilder;

    const-string v1, " apps._id="

    invoke-direct {v2, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {p1}, Landroid/net/Uri;->getPathSegments()Ljava/util/List;

    move-result-object v1

    const/4 v3, 0x1

    invoke-interface {v1, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/String;

    invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/database/sqlite/SQLiteQueryBuilder;->appendWhere(Ljava/lang/CharSequence;)V

    goto :goto_3

    .line 254
    :sswitch_4
    new-instance v2, Ljava/lang/StringBuilder;

    const-string v1, "apps._id="

    invoke-direct {v2, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {p1}, Landroid/net/Uri;->getPathSegments()Ljava/util/List;

    move-result-object v1

    const/4 v3, 0x1

    invoke-interface {v1, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/String;

    invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/database/sqlite/SQLiteQueryBuilder;->appendWhere(Ljava/lang/CharSequence;)V

    goto :goto_3

    .line 257
    :sswitch_5
    new-instance v2, Ljava/lang/StringBuilder;

    const-string v1, " apps.uid="

    invoke-direct {v2, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {p1}, Landroid/net/Uri;->getPathSegments()Ljava/util/List;

    move-result-object v1

    const/4 v3, 0x2

    invoke-interface {v1, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/String;

    invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/database/sqlite/SQLiteQueryBuilder;->appendWhere(Ljava/lang/CharSequence;)V

    goto/16 :goto_3

    .line 260
    :sswitch_6
    new-instance v2, Ljava/lang/StringBuilder;

    const-string v1, "apps.uid="

    invoke-direct {v2, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {p1}, Landroid/net/Uri;->getPathSegments()Ljava/util/List;

    move-result-object v1

    const/4 v3, 0x2

    invoke-interface {v1, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/String;

    invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/database/sqlite/SQLiteQueryBuilder;->appendWhere(Ljava/lang/CharSequence;)V

    goto/16 :goto_3

    .line 263
    :sswitch_7
    new-instance v2, Ljava/lang/StringBuilder;

    const-string v1, "logs.type="

    invoke-direct {v2, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {p1}, Landroid/net/Uri;->getPathSegments()Ljava/util/List;

    move-result-object v1

    const/4 v3, 0x2

    invoke-interface {v1, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/String;

    invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/database/sqlite/SQLiteQueryBuilder;->appendWhere(Ljava/lang/CharSequence;)V

    goto/16 :goto_3

    .line 266
    :sswitch_8
    new-instance v2, Ljava/lang/StringBuilder;

    const-string v1, "apps.allow="

    invoke-direct {v2, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {p1}, Landroid/net/Uri;->getPathSegments()Ljava/util/List;

    move-result-object v1

    const/4 v3, 0x2

    invoke-interface {v1, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/String;

    invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/database/sqlite/SQLiteQueryBuilder;->appendWhere(Ljava/lang/CharSequence;)V

    goto/16 :goto_3

    .line 280
    .restart local v8       #c:Landroid/database/Cursor;
    :catch_0
    move-exception v10

    .line 281
    .local v10, e:Landroid/database/sqlite/SQLiteException;
    const-string v1, "Su.PermissionsProvider"

    const-string v2, "Query failed, returning null cursor."

    invoke-static {v1, v2, v10}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto/16 :goto_4

    .line 215
    :sswitch_data_0
    .sparse-switch
        0x64 -> :sswitch_0
        0x65 -> :sswitch_0
        0x66 -> :sswitch_1
        0x67 -> :sswitch_0
        0x68 -> :sswitch_1
        0x69 -> :sswitch_2
        0x6a -> :sswitch_2
        0xc8 -> :sswitch_1
        0xca -> :sswitch_1
        0xcb -> :sswitch_1
    .end sparse-switch

    .line 248
    :sswitch_data_1
    .sparse-switch
        0x65 -> :sswitch_3
        0x66 -> :sswitch_4
        0x67 -> :sswitch_5
        0x68 -> :sswitch_6
        0x6a -> :sswitch_8
        0xca -> :sswitch_4
        0xcb -> :sswitch_7
    .end sparse-switch
.end method

.method public update(Landroid/net/Uri;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;)I
    .locals 7
    .parameter "uri"
    .parameter "values"
    .parameter "selection"
    .parameter "selectionArgs"

    .prologue
    .line 357
    invoke-direct {p0}, Lcom/noshufou/android/su/provider/PermissionsProvider;->ensureDb()Z

    move-result v2

    if-nez v2, :cond_0

    const/4 v0, -0x1

    .line 394
    :goto_0
    return v0

    .line 359
    :cond_0
    const/4 v0, 0x0

    .line 361
    .local v0, count:I
    const/4 v1, 0x0

    .line 362
    .local v1, updatePermissionsDb:Z
    const-string v2, "dirty"

    invoke-virtual {p2, v2}, Landroid/content/ContentValues;->containsKey(Ljava/lang/String;)Z

    move-result v2

    if-nez v2, :cond_1

    .line 363
    const-string v2, "Su.PermissionsProvider"

    const-string v3, "Row dirty, update permissions.sqlite"

    invoke-static {v2, v3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 364
    const-string v2, "dirty"

    const-string v3, "1"

    invoke-virtual {p2, v2, v3}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 365
    const/4 v1, 0x1

    .line 369
    :goto_1
    sget-object v2, Lcom/noshufou/android/su/provider/PermissionsProvider;->sUriMatcher:Landroid/content/UriMatcher;

    invoke-virtual {v2, p1}, Landroid/content/UriMatcher;->match(Landroid/net/Uri;)I

    move-result v2

    packed-switch v2, :pswitch_data_0

    .line 388
    :pswitch_0
    new-instance v2, Ljava/lang/IllegalArgumentException;

    new-instance v3, Ljava/lang/StringBuilder;

    const-string v4, "Unsupported URI: "

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v2

    .line 367
    :cond_1
    const-string v2, "Su.PermissionsProvider"

    const-string v3, "Row not dirty, don\'t update permissions.sqlite"

    invoke-static {v2, v3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_1

    .line 371
    :pswitch_1
    iget-object v2, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    const-string v3, "apps"

    invoke-virtual {v2, v3, p2, p3, p4}, Landroid/database/sqlite/SQLiteDatabase;->update(Ljava/lang/String;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;)I

    move-result v0

    .line 390
    :goto_2
    if-eqz v1, :cond_2

    .line 391
    iget-object v2, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mContext:Landroid/content/Context;

    invoke-static {v2}, Lcom/noshufou/android/su/util/Util;->updatePermissionsDb(Landroid/content/Context;)V

    .line 393
    :cond_2
    invoke-virtual {p0}, Lcom/noshufou/android/su/provider/PermissionsProvider;->getContext()Landroid/content/Context;

    move-result-object v2

    invoke-virtual {v2}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v2

    const/4 v3, 0x0

    invoke-virtual {v2, p1, v3}, Landroid/content/ContentResolver;->notifyChange(Landroid/net/Uri;Landroid/database/ContentObserver;)V

    goto :goto_0

    .line 374
    :pswitch_2
    iget-object v3, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    const-string v4, "apps"

    .line 375
    new-instance v5, Ljava/lang/StringBuilder;

    const-string v2, "_id="

    invoke-direct {v5, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {p1}, Landroid/net/Uri;->getPathSegments()Ljava/util/List;

    move-result-object v2

    const/4 v6, 0x1

    invoke-interface {v2, v6}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/String;

    invoke-virtual {v5, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    .line 376
    invoke-static {p3}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v2

    if-nez v2, :cond_3

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v6, " AND ("

    invoke-direct {v2, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 377
    invoke-virtual {v2, p3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v6, ")"

    invoke-virtual {v2, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 376
    :goto_3
    invoke-virtual {v5, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 375
    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 374
    invoke-virtual {v3, v4, p2, v2, p4}, Landroid/database/sqlite/SQLiteDatabase;->update(Ljava/lang/String;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;)I

    move-result v0

    .line 379
    goto :goto_2

    .line 377
    :cond_3
    const-string v2, ""

    goto :goto_3

    .line 381
    :pswitch_3
    iget-object v3, p0, Lcom/noshufou/android/su/provider/PermissionsProvider;->mDb:Landroid/database/sqlite/SQLiteDatabase;

    const-string v4, "apps"

    .line 382
    new-instance v5, Ljava/lang/StringBuilder;

    const-string v2, "uid="

    invoke-direct {v5, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {p1}, Landroid/net/Uri;->getPathSegments()Ljava/util/List;

    move-result-object v2

    const/4 v6, 0x2

    invoke-interface {v2, v6}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/String;

    invoke-virtual {v5, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    .line 383
    invoke-static {p3}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v2

    if-nez v2, :cond_4

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v6, " AND ("

    invoke-direct {v2, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 384
    invoke-virtual {v2, p3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v6, ")"

    invoke-virtual {v2, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 383
    :goto_4
    invoke-virtual {v5, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 382
    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 381
    invoke-virtual {v3, v4, p2, v2, p4}, Landroid/database/sqlite/SQLiteDatabase;->update(Ljava/lang/String;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;)I

    move-result v0

    .line 386
    goto/16 :goto_2

    .line 384
    :cond_4
    const-string v2, ""

    goto :goto_4

    .line 369
    :pswitch_data_0
    .packed-switch 0x64
        :pswitch_1
        :pswitch_2
        :pswitch_0
        :pswitch_3
    .end packed-switch
.end method
